var oScorm = pipwerks.SCORM;  	// define a SCORM object to interface with PIPWerks code
    
	// This function initializes the course by connecting to the LMS and retrieving 
	// the student's name.
	function initCourse()
	{
		//alert( "lmsConnected = " + lmsConnected );
  		var lmsConnected = oScorm.init();
		if( lmsConnected )
		{
            // always set the status to incomplete
			oScorm.set("cmi.lesson_status", "incomplete");
			oScorm.set("cmi.success.status", "unknown");
		}
	}
    
    // Call this function at the very end of the course when the final
    // score has been calculated.
	function setScore( nScore )
	{
		//alert( "before: " + nScore );
        // Set the values and status here
        
        oScorm.set( "cmi.score.min", "0" );
        
        oScorm.set( "cmi.score.max", "100" );
        oScorm.set( "cmi.score.raw", nScore );
        oScorm.set( "cmi.score.scaled", ( nScore / 100 ) );
        oScorm.set( "cmi.completion_status", "completed" );
        
        if( nScore >= 80 )
        	oScorm.set( "cmi.success.status", "passed" );
        else
        	oScorm.set( "cmi.success_status", "failed" );
        	
        	

	}
	
	// This function is called when the window is closed.  It saves and quits the course.
	function finishCourse()
	{
		oScorm.save();
		oScorm.quit();
	}
